package com.accp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.accp.common.DataResult;
import com.accp.entity.Hotevents;
import com.accp.service.HoteventsService;
import com.baomidou.mybatisplus.core.metadata.IPage;

import io.swagger.annotations.Api;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jack
 * @since 2021-08-03
 */
@RestController
@RequestMapping("/hotevents")
@Api(tags = "热门事件接口")
public class HoteventsController {
	
	@Autowired
	HoteventsService eventService;

	// 分页查询
	@GetMapping("/page")
	public DataResult getEventByPage(
			@RequestParam(required=false,defaultValue="1") int pageIndex, 
			@RequestParam(required=false,defaultValue="3") int pageRows, 
			@RequestParam(required=false,defaultValue="") String keyword) {
		IPage<Hotevents> ipage = this.eventService.getEventByPage(pageIndex, pageRows, keyword);
		return DataResult.getSuccessResult(ipage);
	}

	// 查询事件详情
	@GetMapping("/fetch")
	public DataResult fetchEvent(int id) {
		Hotevents event = this.eventService.fetchEvent(id);
		return DataResult.getSuccessResult(event);
		
	}
}
